home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 3
/
CU Amiga Magazine's Super CD-ROM 03 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-09].iso
/
misc
/
readers_utils
/
aslplaysound
/
aslplaysound.s
< prev
next >
Wrap
Text File
|
1992-09-02
|
5KB
|
443 lines
;ASlPlaySound
;By Mark Retallack
;includes
include exec/exec.i
include exec/exec_lib.i
include libraries/asl.i
include libraries/asl_lib.i
include dos/dos_lib.i include dos commands
include dos/dos.i include dos working
FSGetSize EQU -30
FSLoadSound EQU -36
FSPlaySound EQU -42
FSStopSound EQU -48
CALLFU MACRO
move.l _futurebase,a6
jsr FS\1(a6)
ENDM
;start of program -- open asl lib
lea aslname(pc),a1
moveq #0,d0 dont care which version
CALLEXEC OpenLibrary
tst.l d0
beq exitcloseall if didnt open
move.l d0,_ASLBase store lib pointer
; open dos lib
lea dosname(pc),a1 Find dos name
moveq #0,d0 Store version into d0
CALLEXEC OpenLibrary Call open lib
tst.l d0 Test do
beq exitcloseasl If false then goaway
move.l d0,_DOSBase Put address into DOSBase
; open the Future library
lea funame(pc),a1 store funame in a1
moveq #0,d0 dont care which version
CALLEXEC OpenLibrary
tst.l d0 test d0 and set flag z if lib was opened
beq exitclosedos if flag z is not set goto goawayfast
move.l d0,_futurebase
;find handle
CALLDOS Output Call output
move.l d0,_stdout Move address to stdout
;alloc the requester
move.l #0,d0
lea tags(pc),a0
CALLASL AllocAslRequest
move.l d0,aslreq
;run the requester
runreq
move.l aslreq,a0
lea tags(pc),a1
CALLASL AslRequest
move.l d0,aslres
;test output
cmp #0,d0
beq freereq
;update the patten
move.l aslreq,a0
move.l 52(a0),a0
lea pattern,a1
loop: MOVE.B (A0)+,(A1)+
BNE.S loop
;set the addresses
settheaddrs
move.l #0,lstore
loopy2 add.l #1,lstore
move.l aslreq,a0
move.l 36(a0),d0
move.l lstore,d2
sub.l #1,d2
mulu.l #8,d2
add.l #4,d2
add.l d2,d0
move.l d0,a0
move.l (a0),aslfile
move.l aslreq,a0
move.l 8(a0),asldir
MOVE.L asldir,A0
lea path,A1
cp: MOVE.B (A0)+,(A1)+
BNE.S cp
suba #2,a1
cmp.b #':',(A1)+
beq begin
move.b #'/',(A1)+
begin:
move.l aslfile,a0
cq: move.b (A0)+,(A1)+
BNE.S cq
move.b #10,(A1)+
;get the size of the file
lea path,a0
CALLFU GetSize
tst.l d0
beq runreq
move.l d0,d7
;free the memory
move.l d7,d0
move.l #65538,d1
CALLEXEC AllocMem
tst.l d0
beq runreq
move.l d0,d6
;load in sound
move.l d6,a0
move.l #path,d0
CALLFU LoadSound
tst.l d0
beq runreq
move.l d0,d5
move.w d0,frqstore
;caluclate the period
move.l #3579545,d1
divu d5,d1
move.l d1,d5
;playsound
move.l d6,a0
move.l d7,d0
move.l #1,d1
move.l d5,d2
move.l #64,d3
CALLFU PlaySound
move.l d0,d4
move.l aslreq,a0
move.l 32(a0),d2
move.l lstore,d0
cmp.l d2,d0
beq noloopy2
;delay a bit
move.l #0,d1
move.w frqstore,d1
move.l d7,d0
divu.l #1000,d1
divu.l d1,d0
divu.l #20,d0
add.l #10,d0
move.l d0,d1
CALLDOS Delay
;stop sound
move.l d4,a0
CALLFU StopSound
;free the memory
move.l d6,a1
move.l d7,d0
CALLEXEC FreeMem
bra loopy2
noloopy2
;rereq the sound file
move.l aslreq,a0
lea tags(pc),a1
CALLASL AslRequest
move.l d0,aslres
;test output
cmp #0,d0
beq exitpress
;update the patten
move.l aslreq,a0
move.l 52(a0),a0
lea pattern,a1
loop2: MOVE.B (A0)+,(A1)+
BNE.S loop2
;stop sound
move.l d4,a0
CALLFU StopSound
;free the memory
move.l d6,a1
move.l d7,d0
CALLEXEC FreeMem
bra settheaddrs
;if exit was hit.
exitpress
;stop sound
move.l d4,a0
CALLFU StopSound
;free the memory
move.l d6,a1
move.l d7,d0
CALLEXEC FreeMem
;free the requester
freereq
move.l aslreq,a0
CALLASL FreeAslRequest
;close future library
exitclosefut
move.l _futurebase,a1
CALLEXEC CloseLibrary
;close dos lib
exitclosedos
move.l _DOSBase,a1 base needed in a1
CALLEXEC CloseLibrary
;close asl lib
exitcloseasl
move.l _ASLBase,a1
CALLEXEC CloseLibrary
;end of program
exitcloseall
move #0,d0
rts
;data for program
;strings
version dc.b '$VER: ASLPlaySound V1.1 -- By Mark Retallack 1996',0
funame dc.b 'future.library',0
dosname dc.b 'dos.library',0
aslname dc.b 'asl.library',0
title dc.b 'Select Sample To Play:',0
runs dc.b 'Play',0
cancel dc.b 'Exit',0
pattern dc.b '~(#?.info)',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;storage
_stdout ds.l 1
_futurebase ds.l 1
_DOSBase ds.l 1
_ASLBase ds.l 1
aslreq ds.l 1
aslres ds.l 1
asldir ds.l 1
aslfile ds.l 1
lstore ds.l 1
frqstore ds.w 1
path ds.b 160
;tags for requester
tags dc.l ASL_Hail,title
dc.l ASL_FuncFlags,FILF_MULTISELECT|FILF_PATGAD
dc.l ASL_LeftEdge,50
dc.l ASL_TopEdge,11
dc.l ASL_Width,300
dc.l ASL_Height,200
dc.l ASL_OKText,runs
dc.l ASL_CancelText,cancel
dc.l ASL_Pattern,pattern
dc.l 0